package com.shop.cereshop.agent.controller.agreement;

import com.shop.cereshop.commons.domain.agreement.Agreement;
import com.shop.cereshop.commons.enums.agreement.AgreementVersionEnum;
import com.shop.cereshop.commons.result.Result;
import com.shop.cereshop.agent.service.agreement.AgentAgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author lx
 * @date 2025/10/17 10:10
 * @version 1.0
 */
@RestController
@RequestMapping("/agreement")
@Api(value = "AgentAgreementController", tags = "代理商协议")
@RequiredArgsConstructor
public class AgentAgreementController {

    private final AgentAgreementService agentAgreementService;

    @GetMapping("getByType")
    @ApiOperation(value = "获取协议")
    public Result<Agreement> getByType(@RequestParam @ApiParam(value = "协议类型", required = true) String typeCode,
                                       @RequestParam @ApiParam(value = "角色类型(1-用户端，2-商家端，3-代理商端，4-业务员端)", required = true) Integer roleType) {
        return Result.success(agentAgreementService.getByType(typeCode, AgreementVersionEnum.getMsgByCode(roleType)));
    }
}
